import { PageNames } from '@/router/routes/pagenames'
import { RouteMap } from '@/typings/router'

const Pages: Record<string, RouteMap> = {
    [PageNames.LAYOUT_IFRAME]: {
        path: '/iframe/:name',
        component: () => import('@/layouts/iframe-layout/index.vue'),
        props: (route) => {
            return {
                src: route.query.url as string,
                needToken: route.query.t ?? (false as boolean)
            }
        }
    },
    [PageNames.LOGIN]: {
        path: '/login',
        component: () => import('@/views/_builtin/login/index.vue'),
        props: (route) => {
            const moduleType =
                (route.params.module as UnionKey.LoginModule) || 'pwd-login'
            return {
                module: moduleType
            }
        },
        meta: {
            title: '登录',
            auth: false,
            layout: PageNames.LAYOUT_BLANK,
            autoMount: true
        }
    },
    [PageNames.HOME]: {
        path: import.meta.env.VITE_ROUTE_HOME_PATH,
        component: () => {
            return import('@/views/home/index.vue')
        },
        meta: {
            title: import.meta.env.VITE_ROUTE_HOME_TITLE,
            icon: 'icon-park-outline:analysis'
        }
    },
    [PageNames._403]: {
        path: '/403',
        component: () => import('@/views/_builtin/403/index.vue'),
        meta: {
            title: '无权限',
            auth: false,
            layout: PageNames.LAYOUT_BLANK,
            autoMount: true
        }
    },
    [PageNames._404]: {
        path: '/404',
        component: () => import('@/views/_builtin/404/index.vue'),
        meta: {
            title: '未找到',
            auth: false,
            layout: PageNames.LAYOUT_BLANK,
            autoMount: true
        }
    },
    [PageNames.NOT_FOUND]: {
        path: '/:pathMatch(.*)*',
        component: () => import('@/views/_builtin/404/index.vue'),
        meta: {
            title: '未找到',
            auth: false,
            layout: PageNames.LAYOUT_BLANK,
            autoMount: true
        }
    },
    [PageNames._500]: {
        path: '/500',
        component: () => import('@/views/_builtin/500/index.vue'),
        meta: {
            title: '服务器错误',
            auth: false,
            layout: PageNames.LAYOUT_BLANK,
            autoMount: true
        }
    },
    [PageNames.USER_NOTICE]: {
        path: '/user/notice',
        component: () => import('@/views/_builtin/individual/notice/index.vue'),
        meta: {
            title: '个人消息通知',
            icon: 'ant-design:sound-outlined',
            autoMount: true
        }
    }
}
export default Pages
